package com.test.demo.component;

import com.test.demo.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class HelloComponent {
    @Autowired
    private Student student;
    public void print(){
        System.out.println("hello,component");
    }

    @Bean("st1")
    public Student getStudent1(){
        Student student = new Student();
        student.setName("lzw");
        student.setAge(18);
        return student;
    }
    @Bean({"st","st2"})
    public Student getStudent2(){
        Student student = new Student();
        student.setName("lindan");
        student.setAge(18);
        return student;
    }
    public void getStudent6(){
        System.out.println(student.getName());
    }
}
